<!DOCTYPE html>


<html lang="zh-Hans">


<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
     40+岁大龄码农的自我修养
  </title>
  <meta name="generator" content="hexo-theme-ayer">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/dist/main.css">

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">
  
<link rel="stylesheet" href="/css/custom.css">

  
  <script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
  
  

  

<link rel="alternate" href="/atom.xml" title="40+岁大龄码农的自我修养" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    
      
    <main class="content on">
      



<!-- Subtitle -->

<div id="main">
  <section class="outer">
  
  
  <article class="articles">
    
    
    
    
    <article
  id="post-idea-plugs-md"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2017/11/20/idea-plugs-md/"
    >idea常用插件与配置</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2017/11/20/idea-plugs-md/" class="article-date">
  <time datetime="2017-11-20T10:37:01.000Z" itemprop="datePublished">2017-11-20</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <ul>
<li>颜色主题， Monokai_2</li>
<li>java类模板</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;**</span><br><span class="line"> * @author: 个人姓名</span><br><span class="line"> * @date: $&#123;DATE&#125; $&#123;TIME&#125;</span><br><span class="line"> * @className: $&#123;NAME&#125;</span><br><span class="line"> * @description:</span><br><span class="line"> *&#x2F;</span><br></pre></td></tr></table></figure>

<ul>
<li><p>插件</p>
<ul>
<li>阿里, 插件搜索 alibaba <a target="_blank" rel="noopener" href="https://segmentfault.com/a/1190000011560013">参考</a></li>
<li>FindBugs-IDEA</li>
<li>GsonFormat <a target="_blank" rel="noopener" href="http://blog.csdn.net/qq496013218/article/details/72957434">参考1</a> <a target="_blank" rel="noopener" href="https://github.com/YiiGuxing/TranslationPlugin">参考2</a></li>
<li>Translation 有道翻译 <a target="_blank" rel="noopener" href="https://github.com/YiiGuxing/TranslationPlugin">参考</a></li>
<li>HighlightBracketPair 括号高亮<br><a target="_blank" rel="noopener" href="http://www.cnblogs.com/a8457013/p/7814335.html">参考</a></li>
</ul>
</li>
<li><p>全局jdk版本设置<br>File-Other Setting-Default Project Structure<br>  <img src="https://ww1.sinaimg.cn/large/4399c9a5gy1floqaq8bbtj20j309kmyq.jpg"></p>
</li>
<li><p>设置:</p>
<ul>
<li>方法之间加横线<br>setting-editor-general-appearance-show method separators<br><img src="https://ww1.sinaimg.cn/large/7293e3b7ly1fpg73cxbf5j20zc0js0vw.jpg"> </li>
</ul>
</li>
</ul>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/mac/" rel="tag">mac</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-asyncio-aiohttop-hupu-spider"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2017/08/17/asyncio-aiohttop-hupu-spider/"
    >用asyncio协程和aiohttp爬取虎扑步行街前100页的主贴</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2017/08/17/asyncio-aiohttop-hupu-spider/" class="article-date">
  <time datetime="2017-08-17T12:11:01.000Z" itemprop="datePublished">2017-08-17</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br></pre></td><td class="code"><pre><span class="line">#!&#x2F;usr&#x2F;bin&#x2F;env python</span><br><span class="line"># -*- coding: utf-8 -*-</span><br><span class="line">import asyncio</span><br><span class="line">import aiohttp</span><br><span class="line">import time</span><br><span class="line">from pyquery import PyQuery as pq</span><br><span class="line">import sys</span><br><span class="line">import codecs</span><br><span class="line">import json</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">async def get_post_url(url):</span><br><span class="line">    &#39;&#39;&#39;</span><br><span class="line">    得到每一页的所有链接</span><br><span class="line">    &#39;&#39;&#39;</span><br><span class="line">    async with aiohttp.ClientSession() as client:</span><br><span class="line">        async with client.get(url) as response:</span><br><span class="line">            body &#x3D; await response.text(encoding&#x3D;&quot;utf-8&quot;)</span><br><span class="line">            # print(body)</span><br><span class="line">            post_list &#x3D; parser(body)</span><br><span class="line">            for post_url in post_list:</span><br><span class="line">                post &#x3D; &#123;&#125;</span><br><span class="line">                post[&quot;url&quot;] &#x3D; post_url</span><br><span class="line">                post_urls.append(post_url)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">async def get_post_info(url):</span><br><span class="line">    &#39;&#39;&#39;</span><br><span class="line">    根据链接得到标题 作者 发帖时间等内容</span><br><span class="line">    &#39;&#39;&#39;</span><br><span class="line">    async with aiohttp.ClientSession() as client:</span><br><span class="line">        async with client.get(url) as response:</span><br><span class="line">            body &#x3D; await response.text(encoding&#x3D;&quot;utf-8&quot;)</span><br><span class="line">            post_info &#x3D; paser_post(body)</span><br><span class="line">            if post_info is not None:</span><br><span class="line">                post_info[&quot;url&quot;] &#x3D; url</span><br><span class="line">                post_lists.append(post_info)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def paser_post(html):</span><br><span class="line">    &#39;&#39;&#39;</span><br><span class="line">    解析列表页</span><br><span class="line">    &#39;&#39;&#39;</span><br><span class="line">    post_info &#x3D; &#123;&#125;</span><br><span class="line">    doc &#x3D; pq(html)</span><br><span class="line">    main_post &#x3D; doc(&#39;div#tpc&#39;)</span><br><span class="line">    post_author &#x3D; main_post.find(&#39;div.author a.u&#39;).text()</span><br><span class="line">    post_time &#x3D; main_post.find(&#39;div.author span.stime&#39;).text()</span><br><span class="line">    post_title &#x3D; doc(&#39;h1#j_data&#39;).text()</span><br><span class="line">    post_info[&quot;title&quot;] &#x3D; post_title</span><br><span class="line">    post_info[&#39;time&#39;] &#x3D; post_time</span><br><span class="line">    post_info[&#39;author&#39;] &#x3D; post_author</span><br><span class="line">    if not post_title and not post_time and not post_author:</span><br><span class="line">        return None</span><br><span class="line">    return post_info</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def parser(html):</span><br><span class="line">    &#39;&#39;&#39;</span><br><span class="line">    解析帖子页</span><br><span class="line">    &#39;&#39;&#39;</span><br><span class="line">    post_list &#x3D; []</span><br><span class="line">    doc &#x3D; pq(html)</span><br><span class="line">    links_item &#x3D; doc(&#39;table[id&#x3D;&quot;pl&quot;]&#39;).find(&#39;tbody&#39;).find(&#39;tr[mid]&#39;)</span><br><span class="line">    for link_item in links_item.items():</span><br><span class="line">        post_link &#x3D; link_item.find(&#39;td.p_title&#39;).find(&#39;a&#39;).attr(&#39;href&#39;)</span><br><span class="line">        post_link &#x3D; &quot;https:&#x2F;&#x2F;bbs.hupu.com&quot; + post_link</span><br><span class="line">        post_list.append(post_link)</span><br><span class="line">    return post_list</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"># 得到开始时间</span><br><span class="line">start_time &#x3D; time.time()</span><br><span class="line"># 存储数据的列表</span><br><span class="line">post_lists &#x3D; []</span><br><span class="line"># 每一个帖子链接的列表</span><br><span class="line">post_urls &#x3D; []</span><br><span class="line"># 创建时间循环</span><br><span class="line">loop &#x3D; asyncio.get_event_loop()</span><br><span class="line"></span><br><span class="line"># 将步行街前一百的链接加入事件循环, 同时访问这100页, 得到所有的帖子链接</span><br><span class="line">urls &#x3D; [</span><br><span class="line">    &quot;https:&#x2F;&#x2F;bbs.hupu.com&#x2F;bxj-postdate-&#123;&#125;&quot;.format(i) for i in range(1, 101)]</span><br><span class="line">tasks &#x3D; [get_post_url(url) for url in urls]</span><br><span class="line">loop.run_until_complete(asyncio.wait(tasks))</span><br><span class="line"># 输出帖子总数</span><br><span class="line">print(len(post_urls))</span><br><span class="line"># 将所有帖子链接加入事件循环, 得要内容</span><br><span class="line">for i in range(0, len(post_urls), 1000):</span><br><span class="line">    lenth &#x3D; len(post_urls) - i</span><br><span class="line">    if lenth &gt;&#x3D; 1000:</span><br><span class="line">        lenth &#x3D; 1000</span><br><span class="line">    print(i)</span><br><span class="line">    end_time &#x3D; time.time()</span><br><span class="line">    print(&quot;cast time&quot;, end_time - start_time)</span><br><span class="line">    tasks &#x3D; [get_post_info(post_urls[num + i]) for num in range(lenth)]</span><br><span class="line">    loop.run_until_complete(asyncio.wait(tasks))</span><br><span class="line">loop.close()</span><br><span class="line"></span><br><span class="line"># 存储所有数据.</span><br><span class="line">post_dicts &#x3D; &#123;&quot;posts&quot;: post_lists, &quot;lenth&quot;: len(post_lists)&#125;</span><br><span class="line">with codecs.open(&quot;post.json&quot;, &quot;w&quot;, &quot;utf-8&quot;) as f:</span><br><span class="line">    f.write(json.dumps(post_dicts, indent&#x3D;True))</span><br><span class="line">end_time &#x3D; time.time()</span><br><span class="line"></span><br><span class="line">print(&quot;cast time&quot;, end_time - start_time)</span><br></pre></td></tr></table></figure>

<p>因为虎扑没有登录只能看到前100页的帖子.<br>总共11594个主贴, 总共耗费了358秒.<br>大概每秒爬32个帖子.<br>开了500个协程和1000个协程,速度差不多.<br>应该是单ip的极限了.</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/python/" rel="tag">python</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-bash-tip"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2017/07/18/bash-tip/"
    >bash常用的命令和工具</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2017/07/18/bash-tip/" class="article-date">
  <time datetime="2017-07-18T10:40:26.000Z" itemprop="datePublished">2017-07-18</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <ul>
<li>工具<ul>
<li>1 # thefuck<br>用于输错命令后的自动纠正<ul>
<li>安装<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">brew install thefuck</span><br></pre></td></tr></table></figure></li>
<li>使用<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">pythn</span><br><span class="line"># zsh: command not found: pythonn</span><br><span class="line">fuck</span><br><span class="line"># python [enter&#x2F;↑&#x2F;↓&#x2F;ctrl+c]</span><br></pre></td></tr></table></figure></li>
</ul>
</li>
<li>2 # tldr<br>用于bash命令的提示和示例<ul>
<li>安装<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">brew install tldr</span><br></pre></td></tr></table></figure></li>
</ul>
</li>
<li>使用</li>
</ul>
  <img src="https://ww1.sinaimg.cn/large/4399c9a5gy1fho22cpfopj20oz0exad6.jpg"><ul>
<li>3 # mycli<br>支持自动补全和语法高亮的mysql命令行工具<ul>
<li>安装<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">brew install mycli</span><br></pre></td></tr></table></figure></li>
</ul>
</li>
</ul>
</li>
<li>常用命令</li>
</ul>
<table>
<thead>
<tr>
<th align="center">命令</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="center">history</td>
<td align="center">查看命令行历史记录，再用 !n（n 是命令编号）就可以再次执行</td>
</tr>
<tr>
<td align="center">ctrl-a</td>
<td align="center">将光标移至行首</td>
</tr>
<tr>
<td align="center">ctrl-e</td>
<td align="center">将光标移至行尾</td>
</tr>
<tr>
<td align="center">alt-b 和 alt-f</td>
<td align="center">以单词为单位移动光标</td>
</tr>
<tr>
<td align="center">pstree -p</td>
<td align="center">进程树</td>
</tr>
<tr>
<td align="center">ps -ef grep python</td>
<td align="center">显示python的进程</td>
</tr>
<tr>
<td align="center">netstat -lntp 或 ss -plat</td>
<td align="center">检查哪些进程在监听端口</td>
</tr>
<tr>
<td align="center">alias</td>
<td align="center">alias ll=’ls -latr’ 创建了一个新的命令别名 ll</td>
</tr>
<tr>
<td align="center">ln -s</td>
<td align="center">创建软连接</td>
</tr>
<tr>
<td align="center">df -h</td>
<td align="center">查看硬盘分区</td>
</tr>
<tr>
<td align="center">exec $SHELL</td>
<td align="center">重启shell</td>
</tr>
</tbody></table>
<ul>
<li>技巧<ul>
<li>删除大量文件的最快方法之一<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">mkdir empty &amp;&amp; rsync -r --delete empty&#x2F; some-dir &amp;&amp; rmdir some-dir</span><br></pre></td></tr></table></figure></li>
</ul>
</li>
</ul>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-login-zhihu20170506"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2017/05/06/login-zhihu20170506/"
    >20170506 可用的登录知乎的python代码</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2017/05/06/login-zhihu20170506/" class="article-date">
  <time datetime="2017-05-06T06:03:47.000Z" itemprop="datePublished">2017-05-06</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!/usr/bin/env python</span></span><br><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> requests</span><br><span class="line"><span class="keyword">from</span> bs4 <span class="keyword">import</span> BeautifulSoup</span><br><span class="line"><span class="keyword">import</span> time</span><br><span class="line"><span class="keyword">import</span> json</span><br><span class="line"><span class="keyword">import</span> os</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">url = <span class="string">&#x27;https://www.zhihu.com&#x27;</span></span><br><span class="line">loginURL = <span class="string">&#x27;https://www.zhihu.com/login/email&#x27;</span></span><br><span class="line">headers = &#123;</span><br><span class="line">    <span class="string">&quot;User-Agent&quot;</span>: <span class="string">&#x27;Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0&#x27;</span>,</span><br><span class="line">    <span class="string">&quot;Referer&quot;</span>: <span class="string">&quot;https://www.zhihu.com/&quot;</span>,</span><br><span class="line">    <span class="string">&#x27;Host&#x27;</span>: <span class="string">&#x27;www.zhihu.com&#x27;</span>,</span><br><span class="line">&#125;</span><br><span class="line">data = &#123;</span><br><span class="line">    <span class="string">&#x27;email&#x27;</span>: <span class="string">&#x27;xxxxx&#x27;</span>,</span><br><span class="line">    <span class="string">&#x27;password&#x27;</span>: <span class="string">&#x27;xxxxx&#x27;</span>,</span><br><span class="line">    <span class="string">&#x27;rememberme&#x27;</span>: <span class="string">&quot;true&quot;</span>,</span><br><span class="line">&#125;</span><br><span class="line">s = requests.session()</span><br><span class="line"><span class="keyword">if</span> os.path.exists(<span class="string">&#x27;cookiefile&#x27;</span>):</span><br><span class="line">    <span class="keyword">with</span> <span class="built_in">open</span>(<span class="string">&#x27;cookiefile&#x27;</span>) <span class="keyword">as</span> f:</span><br><span class="line">        cookie = json.load(f)</span><br><span class="line">    s.cookies.update(cookie)</span><br><span class="line">    req1 = s.get(url, headers=headers)</span><br><span class="line">    <span class="comment"># 建立一个zhihu.html文件,用于验证是否登陆成功</span></span><br><span class="line">    <span class="keyword">with</span> <span class="built_in">open</span>(<span class="string">&#x27;zhihu.html&#x27;</span>, <span class="string">&#x27;w&#x27;</span>) <span class="keyword">as</span> f:</span><br><span class="line">        f.write(req1.content)</span><br><span class="line"><span class="keyword">else</span>:</span><br><span class="line">    req = s.get(url, headers=headers)</span><br><span class="line">    <span class="built_in">print</span> req</span><br><span class="line">    soup = BeautifulSoup(req.text, <span class="string">&quot;html.parser&quot;</span>)</span><br><span class="line">    xsrf = soup.find(<span class="string">&#x27;input&#x27;</span>, &#123;<span class="string">&#x27;name&#x27;</span>: <span class="string">&#x27;_xsrf&#x27;</span>, <span class="string">&#x27;type&#x27;</span>: <span class="string">&#x27;hidden&#x27;</span>&#125;).get(<span class="string">&#x27;value&#x27;</span>)</span><br><span class="line">    data[<span class="string">&#x27;_xsrf&#x27;</span>] = xsrf</span><br><span class="line">    timestamp = <span class="built_in">int</span>(time.time() * <span class="number">1000</span>)</span><br><span class="line">    captchaURL = <span class="string">&#x27;https://www.zhihu.com/captcha.gif?=&#x27;</span> + \</span><br><span class="line">        <span class="built_in">str</span>(timestamp) + <span class="string">&quot;&amp;type=login&quot;</span></span><br><span class="line">    <span class="built_in">print</span> captchaURL</span><br><span class="line">    <span class="keyword">with</span> <span class="built_in">open</span>(<span class="string">&#x27;zhihucaptcha.gif&#x27;</span>, <span class="string">&#x27;wb&#x27;</span>) <span class="keyword">as</span> f:</span><br><span class="line">        captchaREQ = s.get(captchaURL, headers=headers)</span><br><span class="line">        f.write(captchaREQ.content)</span><br><span class="line">    loginCaptcha = raw_input(<span class="string">&#x27;input captcha:\n&#x27;</span>).strip()</span><br><span class="line">    data[<span class="string">&#x27;captcha&#x27;</span>] = loginCaptcha</span><br><span class="line">    <span class="built_in">print</span> data</span><br><span class="line">    loginREQ = s.post(loginURL, headers=headers, data=data)</span><br><span class="line">    <span class="keyword">if</span> <span class="keyword">not</span> loginREQ.json()[<span class="string">&#x27;r&#x27;</span>]:</span><br><span class="line">        <span class="built_in">print</span> s.cookies.get_dict()</span><br><span class="line">        <span class="keyword">with</span> <span class="built_in">open</span>(<span class="string">&#x27;cookiefile&#x27;</span>, <span class="string">&#x27;wb&#x27;</span>) <span class="keyword">as</span> f:</span><br><span class="line">            json.dump(s.cookies.get_dict(), f)</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        <span class="built_in">print</span> <span class="string">&#x27;login fail&#x27;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure> 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/python/" rel="tag">python</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-vim-command-personal"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2017/04/17/vim-command-personal/"
    >vim个人常用命令</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2017/04/17/vim-command-personal/" class="article-date">
  <time datetime="2017-04-17T05:10:15.000Z" itemprop="datePublished">2017-04-17</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <ul>
<li><h4 id="按Esc进入普通模式，在该模式下使用方向键或者h-j-k-l键可以移动游标"><a href="#按Esc进入普通模式，在该模式下使用方向键或者h-j-k-l键可以移动游标" class="headerlink" title="按Esc进入普通模式，在该模式下使用方向键或者h,j,k,l键可以移动游标"></a>按Esc进入普通模式，在该模式下使用方向键或者h,j,k,l键可以移动游标</h4></li>
</ul>
<table>
<thead>
<tr>
<th>按键</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>h</td>
<td>左</td>
</tr>
<tr>
<td>l</td>
<td>右</td>
</tr>
<tr>
<td>j</td>
<td>上</td>
</tr>
<tr>
<td>k</td>
<td>下</td>
</tr>
<tr>
<td>w</td>
<td>下一个单词</td>
</tr>
<tr>
<td>b</td>
<td>上一个单词</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody></table>
<ul>
<li><h4 id="在普通模式下使用下面的键将进入插入模式，并可以从相应的位置开始输入"><a href="#在普通模式下使用下面的键将进入插入模式，并可以从相应的位置开始输入" class="headerlink" title="在普通模式下使用下面的键将进入插入模式，并可以从相应的位置开始输入"></a>在普通模式下使用下面的键将进入插入模式，并可以从相应的位置开始输入</h4></li>
</ul>
<table>
<thead>
<tr>
<th>按键</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>i</td>
<td>在当前光标处进行编辑</td>
</tr>
<tr>
<td>I</td>
<td>行首插入</td>
</tr>
<tr>
<td>A</td>
<td>行末插入</td>
</tr>
<tr>
<td>a</td>
<td>在光标后插入</td>
</tr>
<tr>
<td>o</td>
<td>在当前光标处进行编辑</td>
</tr>
<tr>
<td>O</td>
<td>在当前光标处进行编辑</td>
</tr>
<tr>
<td>x</td>
<td>删除游标所在的字符</td>
</tr>
<tr>
<td>dd</td>
<td>删除整行</td>
</tr>
<tr>
<td>D</td>
<td>删除至行尾</td>
</tr>
<tr>
<td>gg</td>
<td>游标移动到到第一行</td>
</tr>
<tr>
<td>G(Shift+g)</td>
<td>到最后一行</td>
</tr>
</tbody></table>
<ul>
<li><h4 id="在普通模式下按-进入命令模式"><a href="#在普通模式下按-进入命令模式" class="headerlink" title="在普通模式下按:进入命令模式,"></a>在普通模式下按:进入命令模式,</h4></li>
</ul>
<table>
<thead>
<tr>
<th>按键</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>set nu</td>
<td>显示行号</td>
</tr>
<tr>
<td>q!</td>
<td>强制退出, 不保存</td>
</tr>
<tr>
<td>q</td>
<td>退出</td>
</tr>
<tr>
<td>wq</td>
<td>保存并退出</td>
</tr>
<tr>
<td>wq!</td>
<td>强制保存并退出</td>
</tr>
</tbody></table>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%BD%AF%E4%BB%B6/" rel="tag">软件</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-vscode-setting"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2017/04/17/vscode-setting/"
    >vscode配置</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2017/04/17/vscode-setting/" class="article-date">
  <time datetime="2017-04-17T04:52:37.000Z" itemprop="datePublished">2017-04-17</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <ul>
<li>按f1输入task,调出运行配置文件<br>  输入</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    &quot;version&quot;: &quot;0.1.0&quot;,</span><br><span class="line">    &quot;command&quot;: &quot;python&quot;,</span><br><span class="line">    &quot;isShellCommand&quot;: true,</span><br><span class="line">    &quot;args&quot;: [&quot;$&#123;file&#125;&quot;],</span><br><span class="line">    &quot;showOutput&quot;: &quot;always&quot;,</span><br><span class="line">    &quot;options&quot;:</span><br><span class="line">        &#123;</span><br><span class="line">        &quot;env&quot;:</span><br><span class="line">            &#123;</span><br><span class="line">            &quot;PYTHONIOENCODING&quot;: &quot;UTF-8&quot;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li><p>常用插件<br>  进辅助线 Guides<br>  文件图标 vscode-icons<br>  缩进线 Indenticator</p>
</li>
<li><p>设置</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 将设置放入此文件中以覆盖默认设置</span><br><span class="line">&#123;</span><br><span class="line">    &quot;window.zoomLevel&quot;: 2,</span><br><span class="line">    &#x2F;&#x2F;字号</span><br><span class="line">    &quot;editor.fontSize&quot;: 14,</span><br><span class="line">    &#x2F;&#x2F; 字体</span><br><span class="line">    &quot;editor.fontFamily&quot;: &quot;Hack, Menlo, Monaco, &#39;Courier New&#39;, monospace&quot;,</span><br><span class="line">    &#x2F;&#x2F;80个字符的提示线</span><br><span class="line">    &quot;editor.rulers&quot;: [80],</span><br><span class="line">    &quot;editor.acceptSuggestionOnEnter&quot;: true,</span><br><span class="line">    &#x2F;&#x2F; Arguments passed in. Each argument is a separate item in the array.</span><br><span class="line">    &#x2F;&#x2F;pep8自动格式化</span><br><span class="line">    &quot;python.formatting.autopep8Args&quot;:[</span><br><span class="line">        &quot;--max-line-length&#x3D;80&quot;,</span><br><span class="line">        &quot;--indent-size&#x3D;4&quot;</span><br><span class="line">    ],</span><br><span class="line"></span><br><span class="line">    &#x2F;&#x2F; Format the document upon saving. 保存文件后自动格式化</span><br><span class="line">    &quot;python.formatting.formatOnSave&quot;: true,</span><br><span class="line">    &#x2F;&#x2F; 忽略的pep8提示</span><br><span class="line">    &quot;python.linting.pylintArgs&quot;: [</span><br><span class="line">        &quot;--include-naming-hint&#x3D;n&quot;,</span><br><span class="line">        &quot;--disable&#x3D;W0311&quot;,</span><br><span class="line">        &quot;--disable&#x3D;C0103&quot;,</span><br><span class="line">        &quot;--disable&#x3D;E1101&quot;,</span><br><span class="line">        &quot;--disable&#x3D;C0111&quot;,</span><br><span class="line">        &quot;--disable&#x3D;W0621&quot;</span><br><span class="line">    ],</span><br><span class="line">    &#x2F;&#x2F;去除尾部的空格</span><br><span class="line">    &quot;files.trimTrailingWhitespace&quot;: true,</span><br><span class="line">    &#x2F;&#x2F;失去焦点时自动保存</span><br><span class="line">    &quot;files.autoSave&quot;: &quot;onFocusChange&quot;,</span><br><span class="line">    &#x2F;&#x2F;显示缩进空格</span><br><span class="line">      &quot;editor.renderWhitespace&quot;: &quot;boundary&quot;,</span><br><span class="line">    &quot;editor.renderLineHighlight&quot;: &quot;line&quot;,</span><br><span class="line">   &#x2F;&#x2F;忽略的文件</span><br><span class="line">  &quot;files.exclude&quot;: &#123;</span><br><span class="line">    &quot;**&#x2F;.git&quot;: true,</span><br><span class="line">    &quot;**&#x2F;.svn&quot;: true,</span><br><span class="line">    &quot;**&#x2F;.hg&quot;: true,</span><br><span class="line">    &quot;**&#x2F;.DS_Store&quot;: true,</span><br><span class="line">        &quot;.vscode&quot;: true,</span><br><span class="line">        &quot;**&#x2F;__pycache__&quot;: true,</span><br><span class="line">        &quot;**&#x2F;**&#x2F;*.pyc&quot;: true</span><br><span class="line">  &#125;,</span><br><span class="line">  &#x2F;&#x2F;关闭显示打开的文件</span><br><span class="line">  &quot;explorer.openEditors.visible&quot;: 0,</span><br><span class="line">  &#x2F;&#x2F;关闭回车的自动补全</span><br><span class="line">    &quot;editor.acceptSuggestionOnEnter&quot;: false</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>需要安装pylint和auto pep8;</p>
<ul>
<li><p> 自己需要的快捷键</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">[</span><br><span class="line">    &#123; &quot;key&quot;: &quot;f6&quot;,                    &quot;command&quot;: &quot;workbench.action.debug.continue&quot;,</span><br><span class="line">                                     &quot;when&quot;: &quot;inDebugMode&quot; &#125;,</span><br><span class="line"></span><br><span class="line">&#123; &quot;key&quot;: &quot;f6&quot;,                    &quot;command&quot;: &quot;workbench.action.debug.start&quot;,</span><br><span class="line">                                     &quot;when&quot;: &quot;!inDebugMode&quot; &#125;,</span><br><span class="line">&#123; &quot;key&quot;: &quot;f5&quot;,           &quot;command&quot;: &quot;workbench.action.tasks.build&quot; &#125;</span><br><span class="line">]</span><br><span class="line"></span><br></pre></td></tr></table></figure></li>
<li><p>不出现自动补全提示的时候,<br>在<code>~/.vscode/extensions/donjayamanne.python-0.5.5/pythonFiles/preview/jedi/parser</code>目录下复制一份grammar3.5.txt,并将其改名为grammar3.6.txt</p>
</li>
</ul>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E8%BD%AF%E4%BB%B6/" rel="tag">软件</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-mac-setting"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2016/10/22/mac-setting/"
    >黑苹果MAC os 10.11新安装后的设置和软件安装</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2016/10/22/mac-setting/" class="article-date">
  <time datetime="2016-10-21T16:20:01.000Z" itemprop="datePublished">2016-10-22</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p>新安装好的系统,需要安装软件和配置,将这些步骤记录下来,以后需要的适合查询.</p>
<ul>
<li>屏蔽”Thunderbolt 1.2 固件更新”<br>黑苹果在APP store更新界面一直有”Thunderbolt 1.2 固件更新”提醒, 在iterm2运行”</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">softwareupdate --ignore ThunderboltFirmwareUpdate1.2</span><br></pre></td></tr></table></figure>

<ul>
<li>安装Xcode Command Line Tools<br>也就是命令行工具,大概需要10分钟.</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">xcode-select --install</span><br></pre></td></tr></table></figure>

<ul>
<li>安装zsh, 命令参考<a target="_blank" rel="noopener" href="https://github.com/robbyrussell/oh-my-zsh">github</a></li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">sh -c &quot;$(curl -fsSL https:&#x2F;&#x2F;raw.github.com&#x2F;robbyrussell&#x2F;oh-my-zsh&#x2F;master&#x2F;tools&#x2F;install.sh)&quot;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>然后配置iterm2, 去掉General的两个Confirm的勾选, 以防iterm2阻止MAC的关机. Profiles-Text两个字号选择18, 字体选择Hack</p>
<p>修改主题和提示符: <code>subl ~/.zshrc</code>, 第10行的主题改成<code>half-life</code>,<br>然后提示符修改代码加入最后,</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">PROMPT&#x3D;$&#39;%&#123;$purple%&#125;%n%&#123;$reset_color%&#125; in %&#123;$limegreen%&#125;%~%&#123;$reset_color%&#125;$(ruby_prompt_info &quot; with%&#123;$fg[red]%&#125; &quot; v g &quot;%&#123;$reset_color%&#125;&quot;)$vcs_info_msg_0_%&#123;$orange%&#125;%&#123;$reset_color%&#125; at %&#123;$hotpink%&#125;%* %&#123;$orange%&#125;</span><br><span class="line">λ%&#123;$reset_color%&#125; &#39;</span><br></pre></td></tr></table></figure>


<ul>
<li>安装brew</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ruby -e &quot;$(curl -fsSL https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;Homebrew&#x2F;install&#x2F;master&#x2F;install)&quot;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<ul>
<li>用brew分别安装各种工具,<br>比如tree, git, openssl, mongodb等.<br>tree是mac下生成目录树的工具,</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">brew install tree</span><br><span class="line">brew install git</span><br><span class="line">brew install openssl</span><br><span class="line">brew python3</span><br><span class="line">brew mysql</span><br></pre></td></tr></table></figure>

<ul>
<li>安装pip</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo easy_install pip</span><br></pre></td></tr></table></figure>

<p>在墙内为了更快的安装各种库, 需要更换pip的安装源,自己建立 “~/.pip/pip.conf”文件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mkdir ~&#x2F;.pip&#x2F;</span><br><span class="line">cd ~&#x2F;.pip&#x2F;</span><br><span class="line">subl pip.conf</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>将</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[global]</span><br><span class="line">trusted-host &#x3D; pypi.douban.com</span><br><span class="line">index-url &#x3D; http:&#x2F;&#x2F;pypi.douban.com&#x2F;simple&#x2F;</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>拷贝进去</p>
<ul>
<li>用pip安装各种库,<br>比如requests, beautifulsoup4, mysql-pyhton, virtualenv等.</li>
</ul>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%BB%91%E8%8B%B9%E6%9E%9C/" rel="tag">黑苹果</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-last-hexo"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2016/09/14/last-hexo/"
    >hexo最新版本的安装和数据恢复</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2016/09/14/last-hexo/" class="article-date">
  <time datetime="2016-09-14T10:47:57.000Z" itemprop="datePublished">2016-09-14</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p>   最近用webstorm运行编辑好的html网页文件,总是显示无法打开,改localhost端口不行. 网上搜索了半天,发现很少人出现这种问题. 我怀疑是MAC osx系统以前装的东西跟webstorm冲突了. 只好重新安装我的黑苹果系统.</p>
<p>   安装一帆风顺,各种软件也安装配置正常. 但是安装和恢复hexo博客文件的时候遇到的问题, 按照以前的方法总是没法恢复成功.只好按hexo 官网的最新方法一步一步的重新安装了.</p>
<ul>
<li>更新github的SSH key, 在终端输入命令一路回车生成SSH</li>
</ul>
 <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">ssh-keygen -t rsa -C &quot;your_email@example.com&quot;</span><br><span class="line"></span><br><span class="line">cd ~&#x2F;.ssh</span><br><span class="line">subl id_rsa.pub</span><br></pre></td></tr></table></figure>

<p>  将sublime text里面的ssh密钥拷贝粘贴到github账户里面.</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">ssh -T git@github.com</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>  验证ssh配置是否成功.</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.name &quot;用户名&quot;</span><br><span class="line">git config --global user.email &quot;邮箱地址&quot;</span><br></pre></td></tr></table></figure>
<p>  运行上面命令,可以避免每次hexo d提交的时候都输入账户密码</p>
<ul>
<li><p>安装Node.js, hexo官网提供的是用命令安装的方式, 我发现还是去Node.js官网下载一个安装程序方便.<br><a target="_blank" rel="noopener" href="https://nodejs.org/download/">下载地址</a></p>
</li>
<li><p>安装Hexo</p>
</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g hexo-cli</span><br></pre></td></tr></table></figure>

<ul>
<li>初始化</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo init mrxin.github.io</span><br><span class="line">cd mrxin.github.io</span><br><span class="line">npm install</span><br></pre></td></tr></table></figure>
<p>完成后, 用 sublime text打开 _config.yml进行配置, 参考以前的配置文件, 需要注意的是, 最后deploy部分,以前type是github,现在改成了git.</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">deploy:</span><br><span class="line">  type: git</span><br><span class="line">  repository: https:&#x2F;&#x2F;github.com&#x2F;MrXin&#x2F;MrXin.github.io.git</span><br><span class="line">  branch: master</span><br></pre></td></tr></table></figure>


<p>这里还有一个重要的步骤是现在需要安装”hexo-deployer-git”,方法:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure>

<ul>
<li>主题安装和配置:<br> 我喜欢的主题叫”Landscape-plus”, 不知道是hexo的bug还是这个主题的不过,标签或者分类只能显示10篇文章的主题.<br> 我又挑了一款不好看的主题,叫maupassant,其<a target="_blank" rel="noopener" href="https://github.com/tufu9441/maupassant-hexo">官网</a>.<br> 使用方法比较简单,按照官方步骤来就行了,最后在多说参数后填上:clutchbear即可.</li>
</ul>
<ul>
<li>最后将以前备份的md文件拷贝到_posts目录里面, 生成静态页面传到github上.</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hexo g</span><br><span class="line">hexo d</span><br></pre></td></tr></table></figure>

<ul>
<li>Rss需要按装插件:</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-generator-feed@1 --save</span><br></pre></td></tr></table></figure> 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/hexo/" rel="tag">hexo</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-zsh-prompt"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2016/09/13/zsh-prompt/"
    >修改zsh命令提示符</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2016/09/13/zsh-prompt/" class="article-date">
  <time datetime="2016-09-13T06:05:35.000Z" itemprop="datePublished">2016-09-13</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <p>修改zsh命令提示符</p>
<ul>
<li><p>安装好zsh后， 打开终端，输入</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim ~&#x2F;.zshrc</span><br></pre></td></tr></table></figure>
<p>打开zsh配置文件</p>
</li>
<li><p>在.zshrc最下面加入</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">autoload -U compinit promptinit</span><br><span class="line">compinit</span><br><span class="line">promptinit</span><br><span class="line"></span><br><span class="line"># 设置 redhat 主题的默认命令行提示符</span><br><span class="line">prompt redhat</span><br></pre></td></tr></table></figure>
<p>启动tab命令补全 和 命令提示符主题,<br>可以用终端命令’prompt -l’或者’prompt -p’查看可用主题</p>
</li>
<li><p>修改保存后,重启终端,可能出现警告</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">zsh compinit: insecure directories, run compaudit for list.</span><br><span class="line">Ignore insecure directories and continue [y] or abort compinit [n]?</span><br></pre></td></tr></table></figure>
<p>按y后,可以出现修改后命令提示符</p>
</li>
</ul>
<p>如果想取消这个警告,在On OSX 10.11下,输入</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd &#x2F;usr&#x2F;local&#x2F;share&#x2F;</span><br><span class="line">sudo chmod -R 755 zsh</span><br><span class="line">sudo chown -R root:staff zsh</span><br></pre></td></tr></table></figure>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%B3%BB%E7%BB%9F/" rel="tag">系统</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
    <article
  id="post-jd-woods"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h2 itemprop="name">
  <a class="article-title" href="/2016/08/23/jd-woods/"
    >python获取京东商品信息</a> 
</h2>
 

    </header>
     
    <div class="article-meta">
      <a href="/2016/08/23/jd-woods/" class="article-date">
  <time datetime="2016-08-23T09:47:04.000Z" itemprop="datePublished">2016-08-23</time>
</a>    
    </div>
      
    <div class="article-entry" itemprop="articleBody">
       
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">#!&#x2F;usr&#x2F;bin&#x2F;env python</span><br><span class="line"># -*- coding: utf-8 -*-</span><br><span class="line"></span><br><span class="line">import requests</span><br><span class="line">from bs4 import BeautifulSoup</span><br><span class="line"></span><br><span class="line">url &#x3D; &#39;http:&#x2F;&#x2F;list.jd.com&#x2F;list.html?cat&#x3D;9987%2C653%2C655&amp;page&#x3D;1&#39;</span><br><span class="line">req &#x3D; requests.get(url)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">soup &#x3D; BeautifulSoup(req.text, &quot;html.parser&quot;)</span><br><span class="line">items &#x3D; soup.select(&#39;li.gl-item&#39;)</span><br><span class="line"># print len(items)</span><br><span class="line">for item in items:</span><br><span class="line">    sku &#x3D; item.find(&#39;div&#39;)[&#39;data-sku&#39;]</span><br><span class="line">    print sku,</span><br><span class="line">    price_url &#x3D; &#39;http:&#x2F;&#x2F;p.3.cn&#x2F;prices&#x2F;mgets?skuIds&#x3D;J_&#39; + str(sku)</span><br><span class="line">    price &#x3D; requests.get(price_url).json()[0][&#39;p&#39;]</span><br><span class="line">    print price,</span><br><span class="line">    nameinfo &#x3D; item.find(&#39;div&#39;, class_&#x3D;&quot;p-name&quot;).find(&#39;a&#39;)</span><br><span class="line">    name &#x3D; nameinfo[&#39;title&#39;]</span><br><span class="line">    item_url &#x3D; &#39;http:&#39; + nameinfo[&#39;href&#39;]</span><br><span class="line">    print name, item_url,</span><br><span class="line">    commit &#x3D; item.find(&#39;div&#39;, class_&#x3D;&quot;p-commit&quot;).find(&#39;a&#39;)</span><br><span class="line">    if commit:</span><br><span class="line">        print commit.get_text()</span><br></pre></td></tr></table></figure>

<p>其中价格是json获取的,</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">http:&#x2F;&#x2F;p.3.cn&#x2F;prices&#x2F;mgets?skuIds&#x3D;J_ + skuId</span><br></pre></td></tr></table></figure>

<p>还有几个获取获取json的方法:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">http:&#x2F;&#x2F;c0.3.cn&#x2F;stock?skuId&#x3D;965009&amp;cat&#x3D;652,829,854&amp;area&#x3D;1_2812_51141_0&amp;extraParam&#x3D;&#123;&quot;originid&quot;:&quot;1&quot;&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>其中skuid是商品id,cat可以在商品网页里面获取到, area是地区码,<br>返回京东网页版商品的价格,当地商品是否有货.</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">http:&#x2F;&#x2F;item.m.jd.com&#x2F;ware&#x2F;thirdAddress.json?address&#x3D;jd1356&amp;wareId&#x3D;965009&amp;provinceId&#x3D;1&amp;cityId&#x3D;2812&amp;countryId&#x3D;51141</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>其中wareID是商品id,area是地区码,返回京东手机版商品的价格,当地商品是否有货.</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">http:&#x2F;&#x2F;pe.3.cn&#x2F;prices&#x2F;pcpmgets?skuids&#x3D;965012&amp;origin&#x3D;5&amp;area&#x3D;1_2812_51141</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>其中skuid是商品id,cat可以在商品网页里面获取到, area是地区码,<br>返回商品网页版价格和手机版微信版价格.</p>
 
      <!-- reward -->
      
    </div>
    

    <!-- copyright -->
    
    <footer class="article-footer">
       
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/python/" rel="tag">python</a></li></ul>

    </footer>
  </div>

    
 
    
</article>

    
  </article>
  

  
  <nav class="page-nav">
    
    <a class="extend prev" rel="prev" href="/">上一页</a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><a class="page-number" href="/page/4/">4</a><span class="space">&hellip;</span><a class="page-number" href="/page/7/">7</a><a class="extend next" rel="next" href="/page/3/">下一页</a>
  </nav>
  
</section>
</div>

      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2015-2022
        <i class="ri-heart-fill heart_icon"></i> 小信
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        Powered by <a href="https://hexo.io" target="_blank">Hexo</a>
        <span class="division">|</span>
        Theme - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>Visitors:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>Views:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="40+岁大龄码农的自我修养"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>

<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->


<link rel="stylesheet" href="/css/clipboard.css">

<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>


<!-- CanvasBackground -->


    
  </div>
</body>

</html>